//
//  RecognizeQRCodeFromImageViewController.m
//  二维码综合案例
//
//  Created by Guo Rui on 2017/10/23.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import "DetectorQRCodeViewController.h"
#import <CoreImage/CoreImage.h>

#import "QRCodeTool.h"

@interface DetectorQRCodeViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *qrImageView;

@end

@implementation DetectorQRCodeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (IBAction)detectorQRCode {
//    __weak typeof(self) weakself = self;
//    [QRCodeTool detectorWithImage:self.qrImageView.image isDrawQRCodeFrame:YES completion:^(NSArray<NSString *> *codeContents, UIImage *resultImage) {
//        weakself.qrImageView.image = resultImage;
//
//        UIAlertController *altController = [UIAlertController alertControllerWithTitle:@"通知" message:codeContents.description preferredStyle:UIAlertControllerStyleAlert];
//        UIAlertAction *action = [UIAlertAction actionWithTitle:@"知道" style:UIAlertActionStyleDefault handler:nil];
//        [altController addAction:action];
//        [self presentViewController:altController animated:YES completion:nil];
//    }];
    
    NSString *message = [QRCodeTool detecteWithImage:self.qrImageView.image].description;
    UIAlertController *altController = [UIAlertController alertControllerWithTitle:@"通知" message:message preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"知道" style:UIAlertActionStyleDefault handler:nil];
    [altController addAction:action];
    [self presentViewController:altController animated:YES completion:nil];
}



@end
